package com.citytransport.prokopjuk.vehicleDTO;

import java.util.Random;

/**
 * Abstract class Vehicle is a base class to some type of transport. Class
 * Vehicle implements interface VehiclePriperties.
 * 
 * @author Prokopj'uk Oleksander
 * @version 1.0
 * */

public abstract class Vehicle implements VehicleProperties {

	private static Random random = new Random();
	private int ID;
	private int seatAmount;
	private String registrationNumber;
	private int routeID;
	private String model;
	

	/**
	 * No-arg constructor
	 * */
	public Vehicle() {
		ID = random.nextInt();
		seatAmount = 0;
		registrationNumber = "Under Construction";
		routeID = 0;
		model = "default model";

	}

	public Vehicle(int seatAmount, String vehicleNumber, String model) {
		ID = random.nextInt();
		this.seatAmount = seatAmount;
		this.registrationNumber = vehicleNumber;
		this.model = model;
		routeID = 0;
	}
	
	public Vehicle(int ID,int seatAmount, String vehicleNumber, String model) {
		this.ID = ID;
		this.seatAmount = seatAmount;
		this.registrationNumber = vehicleNumber;
		this.model = model;
		routeID = 0;
	}
	
	@Override
	public String toString() {
		return this.getClass().getSimpleName() + " :: ID = " + getID()
				+ " model : " + getModel()
				+ " amount of seats = " + getSeatAmount()
				+ " number of machine  - " + getRegistrationNumber();
	}

	/**
	 * Return unique id of object.
	 * */
	public int getID() {
		return ID;
	}

	/**
	 * Return amount of the seats in vehicle.
	 * */
	public int getSeatAmount() {
		return seatAmount;
	}
	
	public int getRouteID(){
		return routeID;
	}
	
	public void setRouteID(int routeID){
		this.routeID = routeID;
	}
	/**
	 * Change amount of seats.
	 * 
	 * @param seatAmount
	 *            - new value of seatAmount.
	 * */
	public void setSeatAmount(int seatAmount) {
		this.seatAmount = seatAmount;
	}
	

	public String getModel(){
	    return model;
	}
	
	public void setModel(String model){
	    this.model = model;
	}

	/**
	 * Return vehicle registration plate.
	 * */
	public String getRegistrationNumber() {
		return registrationNumber;
	}
	

	/**
	 * Change vehicle registration plate.
	 * 
	 * @param registrationNumber
	 *            - new number.
	 * */
	public void setRegistrationNumber(String registrationNumber) {
		this.registrationNumber = registrationNumber;
	}
	
	public int hashCode(){
		return new Integer(getID()).hashCode() + new Integer(getRouteID()).hashCode()+
					new Integer(getSeatAmount()).hashCode() + getRegistrationNumber().hashCode();
					
	}
}
